Skip to content

test(e2e): add Playwright coverage for Raise Dispute flow#298

Merged
Benjtalkshow merged 4 commits into
boundlessfi:mainfrom
DevSolex:feat/e2e-raise-dispute-280
Jun 29, 2026
Merged

test(e2e): add Playwright coverage for Raise Dispute flow#298
Benjtalkshow merged 4 commits into
boundlessfi:mainfrom
DevSolex:feat/e2e-raise-dispute-280

Conversation

@DevSolex

@DevSolex DevSolex commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Closes #280

What

Adds e2e/raise-dispute.spec.ts covering the full Raise Dispute flow as specified in #280.

Tests (7 cases)

  1. Creator on an IN_PROGRESS bounty sees an active Raise Dispute button
  2. Participant (submitter) on an IN_PROGRESS bounty sees an active Raise Dispute button
  3. Clicking the button opens the AlertDialog with a reason Select and description Textarea
  4. Submitting with empty fields keeps the dialog open and shows inline validation errors
  5. Submitting with a reason but empty description keeps the dialog open with a description error
  6. Valid submission closes the dialog, shows a success toast, and redirects to /dispute/:id
  7. API 500 keeps the dialog open and shows an error toast

Conventions followed

  • Reuses MOCK_SESSION / setupMocks pattern from e2e/bounty-application.spec.ts
  • POST /api/disputes mocked via page.route('**/api/disputes', ...)
  • No arbitrary sleeps — all timing via await expect(...)
  • Selectors use roles and visible labels only

Verified

pnpm exec playwright test e2e/raise-dispute.spec.ts
7 passed (1.4m)

Summary by CodeRabbit

  • Bug Fixes
    • Improved the “Raise a Dispute” flow on bounty detail pages, including clearer handling for validation failures, successful submissions, and server-side errors.
    • Ensured the “Raise a Dispute” button is available and behaves consistently across relevant bounty statuses and user roles.
  • Tests
    • Added end-to-end coverage for the full “Raise Dispute” journey, including request/response assertions and error handling.
  • Chores
    • Centralized and reused Playwright authentication and API mocking utilities for more reliable E2E runs.

@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

@DevSolex is attempting to deploy a commit to the Threadflow Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@DevSolex Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Benjtalkshow, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 53 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d135683e-e0fc-4dd5-b505-1764f69704cd

📥 Commits

Reviewing files that changed from the base of the PR and between a8b0056 and e454aab.

📒 Files selected for processing (2)
  • e2e/bounty-application.spec.ts
  • e2e/helpers/mocks.ts
📝 Walkthrough

Walkthrough

Adds shared Playwright mock helpers, updates bounty-application.spec.ts to use them, and adds raise-dispute.spec.ts with mocked auth, GraphQL, and disputes API coverage for dialog visibility, validation, submission, and error handling.

Changes

Raise Dispute E2E coverage

Layer / File(s) Summary
Shared mock helpers
e2e/helpers/mocks.ts
New module exporting WALLET_ADDRESS, makeSession, stubAuth, stubGraphQL, baseUrlHostname, seedSessionCookie, and LEADERBOARD_STUBS for reuse across specs.
bounty-application refactor to shared helpers
e2e/bounty-application.spec.ts
Imports shared auth helpers, exports setupMocks, and replaces inline auth session mocking and cookie seeding with shared calls.
Raise Dispute spec: constants and setup
e2e/raise-dispute.spec.ts
Defines bounty/user constants, mock Bounty variants, the dispute handler type, the mock wiring for auth, GraphQL, and /api/disputes, and the dialog-opening helper.
Raise Dispute spec: visibility, validation, and submit
e2e/raise-dispute.spec.ts
Tests cover button visibility for creator and contributor on both bounty states, dialog controls, empty-field validation, partial validation, successful submission with redirect and request assertions, and the 500-error case.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

  • boundlessfi/bounties#180: Both PRs touch e2e/bounty-application.spec.ts to consolidate auth and route mocking patterns.
  • boundlessfi/bounties#256: The new spec exercises the Raise Dispute flow introduced there, including /api/disputes submission and redirect behavior.
  • boundlessfi/bounties#299: Both PRs cover the same Raise Dispute UI flow, with this one adding E2E coverage around the dialog and submission path.

Suggested reviewers

  • Benjtalkshow

Poem

🐇 Hop, hop — the tests now know the way,
Auth and GraphQL dance in a hermetic display.
Raise a dispute, the dialog shines bright,
Success or error, the rabbit sees it right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise, specific, and accurately summarizes the main change: new Playwright coverage for the Raise Dispute flow.
Linked Issues check ✅ Passed The PR matches issue #280: it adds the new spec, covers the required scenarios, and reuses the requested mock/session patterns.
Out of Scope Changes check ✅ Passed The helper updates in e2e/helpers/mocks.ts and e2e/bounty-application.spec.ts directly support the new E2E coverage and are in scope.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e/raise-dispute.spec.ts`:
- Around line 29-35: The button-visibility coverage in raise-dispute.spec.ts
only exercises the MOCK_BOUNTY fixture with IN_PROGRESS status, so add a
parallel UNDER_REVIEW eligibility case to the relevant visibility tests
(including the later cases referenced in the comment) by reusing the existing
test flow with a bounty fixture whose status is UNDER_REVIEW and asserting the
same eligible-user behavior. Keep the coverage aligned with the requirement by
updating the tests around MOCK_BOUNTY and the button visibility assertions so
both IN_PROGRESS and UNDER_REVIEW are verified.
- Around line 165-175: The mocked /api/disputes route in raise-dispute.spec.ts
is too permissive because it fulfills any request without validating the request
contract. Tighten the page.route handler by checking the request method and
asserting the JSON payload contains the expected dispute-submit fields
(campaignId, reason, description) before fulfilling, using the existing
disputeHandler branch and the default mock response path to keep the integration
test meaningful.
- Around line 177-186: The auth cookie setup in the raise-dispute e2e flow is
still hardcoded to localhost, which breaks when the test host comes from
BASE_URL. Update the cookie seeding in the relevant Playwright setup to use the
configured base URL/host instead of a fixed domain so it works for 127.0.0.1,
custom hostnames, and remote environments. Keep the change localized to the
cookie creation logic in the raise-dispute spec and ensure it derives the domain
from the same BASE_URL used by playwright.config.ts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9c6d4e8c-9ec0-42bc-b8ae-6b9f79531c10

📥 Commits

Reviewing files that changed from the base of the PR and between 9e5dc91 and 9c8370f.

📒 Files selected for processing (2)
  • e2e/raise-dispute.spec.ts
  • playwright.config.ts

Comment thread e2e/raise-dispute.spec.ts Outdated
Comment thread e2e/raise-dispute.spec.ts
Comment thread e2e/raise-dispute.spec.ts Outdated

@Benjtalkshow Benjtalkshow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is fully green (build, lint, e2e all pass), tests cover every #280
acceptance criterion plus two bonuses, and the validation/toast strings
match the actual implementation in raise-dispute-dialog.tsx. Two things
before merge: please drop the playwright.config.ts changes (BASE_URL env
var support is out of scope for #280 — open a separate PR if it's needed
for your local workflow), and please reuse setupMocks from bounty-
application.spec.ts as #280 asked instead of redefining a fresh one with
a different signature inside this spec — export the existing function and
import it here, or extract a shared e2e/helpers/mocks.ts (PR #304 is also
extracting mocks, ideal would be to coordinate on one shared module).
Once those land, ready to merge.

@Benjtalkshow

Copy link
Copy Markdown
Contributor

Hey @DevSolex ,
Whats the update?

@DevSolex

Copy link
Copy Markdown
Contributor Author

Hey @DevSolex , Whats the update?

On it.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
e2e/bounty-application.spec.ts (1)

130-130: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Don't expose reusable helpers from a *.spec.ts file.

Any later spec that imports setupMocks will also execute this module's top-level test.describe(...), registering the bounty suite as an import side effect. Keep setupMocks private here, or move it into e2e/helpers/ before reusing it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/bounty-application.spec.ts` at line 130, The reusable helper setupMocks
is being exported from a spec file, which can cause importing test modules to
execute bounty suite side effects through the top-level test.describe. Make
setupMocks private within the bounty-application.spec.ts module or move it into
a shared e2e/helpers utility before reusing it, and keep the spec file focused
only on registering its own tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e/helpers/mocks.ts`:
- Around line 105-111: LEADERBOARD_STUBS no longer matches the GraphQL response
shapes that the detail-page tests already consume. Update the shared stub values
in mocks.ts so TopContributors, Leaderboard, GetLeaderboardUser, and
LeaderboardUser return the expected field structure used by the specs (for
example topContributors, leaderboard, and userLeaderboard), and keep the shared
helper aligned with the existing consumers in raise-dispute.spec.ts and
bounty-application.spec.ts.

In `@e2e/raise-dispute.spec.ts`:
- Around line 286-287: The spec has a duplicate capturedRequests declaration
that will break parsing/type-checking before Playwright runs. In
raise-dispute.spec.ts, remove the extra const capturedRequests definition and
keep only one declaration in the relevant test/setup scope, making sure any
later references in the same spec still use that single capturedRequests
variable.

---

Nitpick comments:
In `@e2e/bounty-application.spec.ts`:
- Line 130: The reusable helper setupMocks is being exported from a spec file,
which can cause importing test modules to execute bounty suite side effects
through the top-level test.describe. Make setupMocks private within the
bounty-application.spec.ts module or move it into a shared e2e/helpers utility
before reusing it, and keep the spec file focused only on registering its own
tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 89c3df76-b69e-4868-8400-2ebce560958f

📥 Commits

Reviewing files that changed from the base of the PR and between 9c8370f and 0fc267d.

📒 Files selected for processing (3)
  • e2e/bounty-application.spec.ts
  • e2e/helpers/mocks.ts
  • e2e/raise-dispute.spec.ts

Comment thread e2e/helpers/mocks.ts
Comment thread e2e/raise-dispute.spec.ts
Comment on lines +286 to +287
const capturedRequests: { method: string; body: unknown }[] = [];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Remove the duplicate capturedRequests declaration.

This block declares the same const twice, so the spec will fail to parse/type-check before Playwright can run it.

Minimal fix
-    const capturedRequests: { method: string; body: unknown }[] = [];
     const capturedRequests: { method: string; body: unknown }[] = [];
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const capturedRequests: { method: string; body: unknown }[] = [];
const capturedRequests: { method: string; body: unknown }[] = [];
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/raise-dispute.spec.ts` around lines 286 - 287, The spec has a duplicate
capturedRequests declaration that will break parsing/type-checking before
Playwright runs. In raise-dispute.spec.ts, remove the extra const
capturedRequests definition and keep only one declaration in the relevant
test/setup scope, making sure any later references in the same spec still use
that single capturedRequests variable.

Use makeSession() and LEADERBOARD_STUBS from e2e/helpers/mocks.ts so the
spec matches the pattern raise-dispute.spec already follows. Also type
makeSession's return as a MockSession interface so callers can access
.user fields.
@Benjtalkshow Benjtalkshow merged commit 5e24678 into boundlessfi:main Jun 29, 2026
4 of 5 checks passed
Benjtalkshow added a commit to Johnpii1/bounties-fork that referenced this pull request Jun 29, 2026
Reset branch onto current main so this PR no longer deletes the work
from PRs boundlessfi#298, boundlessfi#311, and boundlessfi#313. Only changes left:

- New hooks/__tests__/use-bounty-application.test.tsx with 12 cases
  covering happy and rollback paths for useApplyToBounty,
  useSelectApplicant, useApproveApplicationSubmission, useRequestRevisions,
  useApplyForSlot, useReleasePayment, useRemoveContributor,
  useDeclineApplicant, and useRaiseDispute.
- Validation in useApplyToBounty that throws ApplicationError when
  applicantAddress is missing. Production guard, not test-only.

Verified pnpm lint, pnpm tsc --noEmit, pnpm build, and the new test
suite (12/12 passing) all clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Playwright e2e coverage for the Raise Dispute flow

2 participants